{% macro rating(obj) %}
<ul id="rate-{{obj.id}}" class="rating star-{{obj.rate}}">
<li class="one"><a onclick="rating('{{obj.label}}', '{{obj.id}}',1)">1</a></li>
<li class="two"><a onclick="rating('{{obj.label}}ic', '{{obj.id}}',2)">2</a></li>
<li class="three"><a onclick="rating('{{obj.label}}', '{{obj.id}}',3)">3</a></li>
<li class="four"><a onclick="rating('{{obj.label}}', '{{obj.id}}',4)">4</a></li>
<li class="five"><a onclick="rating('{{obj.label}}', '{{obj.id}}',5)">5</a></li>
</ul>
{% endmacro %}


{% macro render_pagination(page_now,page_count) %}
<center>
    <ul class="pagination pagination-sm">
    {%- for page in range(1,page_count+1) %}
        {% if page == page_now %}
            <li class="active"><a>{{page}}</a>
        {% elif page == 1 %}
            <li><a href="?page={{page}}">{{page}}</a></li>
            {% if page_now > 1 + 4 %}
                <li><a>...</a></li>
          {% endif %}
        {% elif page == page_count %}
            {% if page_now < page_count - 4 %}
                <li><a>...</a></li>
            {% endif %}
            <li><a href="?page={{page}}">{{page}}</a></li>
        {% elif page > page_now - 4 and page < page_now + 4 %}
          <li><a href="?page={{page}}">{{page}}</a></li>
        {% else %}
        {% endif %}
    {%- endfor %}
    </ul>
</center>
{% endmacro %}


{% macro album_tools(album,siteinfo) %}
<div id="batch_tools" class="row hidden">
    {% if not album.no_filter %}
        <hr />
        <div class="row">
            <div class="col-xs-12 col-sm-12">
                <div class="col-xs-3 col-sm-3 join_btn" id="volume_name_div">
                    <select class="form-control input-sm" id="volume_name">
                        <option value="">卷</option>
                    </select>
                </div>
                <div class="col-xs-3 col-sm-3 join_btn">
                    <select class="form-control input-sm" id="tag_name" multiple="multiple">
                    </select>
                </div>
                <div class="col-xs-3 col-sm-3 join_btn">
                    <select class="form-control input-sm" id="album_name" multiple="multiple">
                    </select>
                </div>
                <div class="col-xs-3 col-sm-3 join_btn">
                    <select class="form-control input-sm" id="actress_name" multiple="multiple">
                    </select>
                </div>
            </div>
        </div>
    {% endif %}

    <hr />
    <div class="row">
        <div class="col-sm-12 col-xs-12" style="color:#aaa">
            <input type="button" class="btn btn-sm btn-info" id="select_all" value="全选">
            <input type="button" class="btn btn-sm btn-info" id="cancel_select" value="取消">
            &nbsp;|&nbsp;

            {% if album.label == 'recycle' %}
                <input type="button" class="btn btn-sm btn-success" value="恢复" id="recycle_restore_btn">
                <input type="button" class="btn btn-sm btn-danger" value="删除" id="recycle_delete_btn">
            {% elif album.label == 'temp' %}
                <input type="button" class="btn btn-sm btn-danger" value="删除" id="delete_temp_pics_btn">
            {% else %}
<!--                <input type="button" class="btn btn-sm btn-warning" value="下载" id="download_pics">-->
<!--                &nbsp;|&nbsp;-->
                <input type="button" class="btn btn-sm btn-danger" value="删除" id="delete_pics_btn">
            {% endif %}

            {% if not album.fake %}
            &nbsp;|&nbsp;
            <input type="button" class="btn btn-sm btn-warning" value="移出" id="move_out_btn">
            {% endif %}

            <span class="pull-right join_btn">
                {% if album.label == 'temp' %}
                    <input type="button" class="btn btn-success btn-sm" id="sorted_import_btn" value="导入">
                {% elif album.label == 'recycle' %}

                {% else %}
                    <input type="button" class="btn btn-primary btn-sm" value="加入" id="join_albums_btn">
                {% endif %}
            </span>
        </div>
    </div>
</div>
{% endmacro %}


{% macro flash_msg() %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
    {% for category, message in messages %}
        <div class="alert alert-{{category}} alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            {{message}}
        </div>
    {% endfor %}
{% endif %}
{% endwith %}
{% endmacro %}